import { Component, OnInit } from '@angular/core';
import {GOODS} from "../../service/goods-api";
import {PageParam} from "../../model/params.model";
import {CheckStandModel} from "../../model/checkstand.model";
import {LocalStorage} from "../../app.local-storage";
import {ROUTE} from "../../service/route.service";

@Component({
  selector: 'app-my-lease-view',
  templateUrl: './my-lease-view.component.html',
  styleUrls: ['./my-lease-view.component.scss']
})
export class MyLeaseViewComponent implements OnInit {
  pageParam:PageParam;
  orderList = [];
  pagination={
    page:1,
    totalPage:1
  }

  constructor(public GOODS:GOODS,public ls:LocalStorage,public route:ROUTE) { }

  ngOnInit() {
    this.pageParam = new PageParam()
    this.pageParam.size = 4;
    this.queryList()
  }
  onPageChanged(v){
    console.log('onPageChanged',v.data.page)
    this.pagination.page = v.data.page
    this.pageParam.page = this.pagination.page-1
    this.queryList()
  }
  queryList() {
    this.GOODS.getRentOrderList(v => {
      this.orderList = v.content
      this.pagination.totalPage = v.totalPages;
    },this.pageParam);
  }
  statusFunc(v){
    if (v.statusName == '待支付'){
      let checkstand = new CheckStandModel(v.orderNo, v.title, v.payMoney, v.id,'personal/mylease')
      this.ls.setObject('checkstand', checkstand);
      this.route.goConfirmPaymentView(v.orderNo);
    }
  }

}
